<template>
    <div><slot></slot></div>
</template>

<script type="text/javascript">
import $ from 'jquery'

export default {
    props: {
        title: {
            type: String,
            default: "多选器"
        },
        unique: {
            type: Boolean,
            default: true
        },
        confirmHandler: {
            type: Function
        },
        cancelHandler: {
            type: Function
        }
    },
    data() {
        var vm = this;
        return {
            state: "pending",
            arr: []
        }
    },
    methods: {
        add(value) {
            this.unique && this.remove(value);
            this.arr.push(value);
        },
        remove(value) {
            var i = this.arr.indexOf(value);
            i != -1 && this.arr.splice(i, 1);
        },
        confirm() {
            var vm = this;
            vm.state = "confirm";
            this.confirmHandler && this.confirmHandler(vm.arr);
            vm.$emit('picker-confirm', vm.arr);
        },
        cancel() {
            this.state = "cancel";
            this.cancelHandler && this.cancelHandler(vm.arr);
            this.$emit('picker-cancel', this.arr);
        }
    },
    created() {
        
    }
}
</script>

<style type="text/css">
    
</style>